
function calcSize(theBlock, numCols, numRows, numHeaderRows, cellPadding, marginSize, weekView)
{
    var w = theBlock.clientWidth;
    var h = theBlock.clientHeight;
    if($SizeToOuterParent$)
    {
        w = theBlock.parentNode.clientWidth;
        h = theBlock.parentNode.clientHeight;
    }
    if(w < 10 || h < 10) return;
    //These are for the margin width
    w -= marginSize;
    h -= marginSize;
    
    var headerHeight = 0;
    var h1 = document.getElementById("h1");
    headerHeight = h1.clientHeight;
    if(numHeaderRows > 0)
        h -= headerHeight;
    
    var totalCellPadding = ((numRows +1 + numHeaderRows)*cellPadding);
    h -= totalCellPadding;
    
    var totalCellPaddingW = (numCols+1)*cellPadding;
    w -= totalCellPaddingW;
    
    var boxes = theBlock.getElementsByTagName("div");
    var re = /day\w*(\d+)?(-(\d+))?/;
    var counter = 0;
    var remainH = h%numRows;
    var remainW = w%numCols;

    var boxCount = 0;
    var lastRow = (numRows*numCols);
    for(var x = 0; x < boxes.length; ++x)
    {
        var box = boxes.item(x);
        var cname = box.className;
        var o = cname.match(re);
        if(o != null)
        {
            var cw = o[1];
            var ch = o[2];
            if(cw == "" || cw == null) cw = 1;
            if(ch == "" || ch == null) ch = 1;
            
            var hh = h/numRows;
            var hh = Math.floor(hh *ch) + ((ch-1)*cellPadding); 
            if(weekView)
                hh -= headerHeight;
            if(weekView && (boxCount%7 == 4 || boxCount%7 == 6))
                box.style.height = Math.floor((hh-cellPadding-headerHeight)/2) + "px";
            else
            {
                if(boxCount > lastRow)
                    hh +=(h%numRows);
                box.style.height = hh + "px";
            }
            
            var ww = w/numCols;
            var ww = Math.floor(ww *cw) + ((cw-1)*cellPadding);
            if(boxCount%numCols == 0)
                ww += w%numCols;
            box.style.width = ww + "px";            
            boxCount++;
        }
        else if(box.className == "header")
        {
            var ww = Math.floor(w/numCols);
            if(boxCount%numCols == 0)
                ww += w%numCols;
            box.style.width = ww + "px";            
            boxCount++;
        }
    }
}

function calcHeight()
{
  if( typeof( window.innerWidth ) == 'number' ) {
     //Non-IE
     myHeight = window.innerHeight;
   } else if( document.documentElement &&
       ( document.documentElement.clientWidth || 
  document.documentElement.clientHeight ) ) {
     //IE 6+ in 'standards compliant mode'
     myHeight = document.documentElement.clientHeight;
   } else if( document.body && ( document.body.clientWidth || 
  document.body.clientHeight ) ) {
     //IE 4 compatible}
     myHeight = document.body.clientHeight;
   }
  return myHeight;
}
function calcWidth()
{
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
     //Non-IE
     myWidth = window.innerWidth;
   } else if( document.documentElement &&
       ( document.documentElement.clientWidth || 
     document.documentElement.clientWidth ) ) {
     //IE 6+ in 'standards compliant mode'
     myWidth = document.documentElement.clientWidth;
   } else if( document.body && ( document.body.clientWidth || 
     document.body.clientWidth ) ) {
     //IE 4 compatible}
     myWidth = document.body.clientWidth;
   }
  return myWidth;
} 
